// 导入组件
import Vue from 'vue';
import Router from 'vue-router';
// 登录
import login from '@/views/login';
import sindex from '@/views/sindex';
import home from '@/views/home'
import menuStree from '@/views/menuStree';
import notFound from '@/views/404'
import Ibookmark from '@/views/bookmark';

// 首页
import index from '@/views/index';
// aaa
import aaa from '@/views/aaa';
//401
import a401 from '@/views/MenuHtml/401';
//书签导入
import Import from '@/views/MenuHtml/Import';
//备忘录
import memorandum from '@/views/MenuHtml/memorandum';
//发现
import discover from '@/views/MenuHtml/discover';
import recycle from '@/views/MenuHtml/recycle';

// 商品管理
import Goods from '@/views/goods/Goods';
// 机器信息管理
import Machine from '@/views/machine/Machine';
// 货道信息管理
import MachineAisle from '@/views/machine/MachineAisle';
/**
 * 订单管理
 */
// 交易订单
import Order from '@/views/pay/Order';
/**
 * 系统管理
 */
/**
 * 书签管理
 */
import webbookmark from '@/views/web/bookmark'


// 用户管理
import user from '@/views/system/user';
// 菜单管理
import Module from '@/views/system/Module';
// 角色管理
import Role from '@/views/system/Role';
// 书签管理
import bookmark from '@/views/system/bookmark';
// 公司管理
import Dept from '@/views/system/Dept';
// 系统环境变量
import Variable from '@/views/system/Variable';
// 权限管理
import Permission from '@/views/system/Permission';
/**
 * 支付管理
 */
// 支付配置信息
import MachineConfig from '@/views/machine/MachineConfig';
// 支付配置
import Config from '@/views/pay/Config';
/**
 * 数据监控
 */
// 监控查询
import druidLogin from '@/views/druid/login';

// 图表界面
import statistics from '@/views/charts/statistics';
// 导航守卫
// const router = new Router({
//   mode: 'history',
//   routes: [
//     {
//       path: '/',
//       redirect: '/login'
//     },
//     {
//       path: '/login',
//       name: 'login',
//       component: login,
//       meta: {
//         // show: true
//         // 添加该字段，表示进入这个路由是需要登录的
//       }
//     },
//     {
//       path: '/login1',
//       name: 'login1',
//       component: login1,
//       meta: {
//         // show: true,
//         requireAuth: true,// 添加该字段，表示进入这个路由是需要登录的
//       }
//     }
//   ]
// });

// 使用 router.beforeEach 注册一个全局前置守卫，判断用户是否登陆














// 启用路由
Vue.use(Router);

// 导出路由 
export default new Router({
    routes: [

      {
        path: '/home',
        name: 'home',
        component: home,
        meta: {
          requireAuth: false
        }
      },

      {
      path: '/sindex',
      name: '',
      component: sindex,
      meta:{
        requireAuth: true,
      },
      children: [
        {
          path: '/bookmark/:menuId',
          component: resolve => require(['../views/bookmark.vue'], resolve),
          query:{
            t:Date.now(),
          },
          meta: {
            requireAuth: true
          }
        },
        {
          path: '/bookmark/:menuId/:seachtitle',
          component: resolve => require(['../views/bookmark.vue'], resolve),
          query:{
            t:Date.now(),
          },
          meta: {
            requireAuth: true,// 添加该字段，表示进入这个路由是需要登录的
          },
        },
        {
          path: '/menuStree',
          name: 'ss',
          component: resolve => require(['../views/menuStree.vue'], resolve),
          meta: {
            requireAuth: true
           }
        },
        {
          path: '/MenuHtml/Import',
          name:'导入书签',
          component: resolve => require(['../views/MenuHtml/Import.vue'], resolve),
          meta: {
            requireAuth: true,// 添加该字段，表示进入这个路由是需要登录的
          },
        },{
          path: '/MenuHtml/follow',
          name:'我关注的人',
          component: resolve => require(['../views/MenuHtml/follow.vue'], resolve),
          meta: {
            requireAuth: true,// 添加该字段，表示进入这个路由是需要登录的
          },
        },
        {
          path: '/MenuHtml/fans',
          name:'我粉丝',
          component: resolve => require(['../views/MenuHtml/fans.vue'], resolve),
          meta: {
            requireAuth: true,// 添加该字段，表示进入这个路由是需要登录的
          },
        },{
          path: '/MenuHtml/memorandum',
          name:'备忘录',
          component: resolve => require(['../views/MenuHtml/memorandum.vue'], resolve),
          meta: {
            requireAuth: true,// 添加该字段，表示进入这个路由是需要登录的
          },
        },{
          path: '/MenuHtml/host',
          name:'热门资讯',
          component: resolve => require(['../views/MenuHtml/host.vue'], resolve),
          meta: {
            requireAuth: true,// 添加该字段，表示进入这个路由是需要登录的
          },
        },{
          path: '/MenuHtml/attention',
          name:'我关注的人',
          component: resolve => require(['../views/MenuHtml/attention.vue'], resolve),
          meta: {
            requireAuth: true,// 添加该字段，表示进入这个路由是需要登录的
          },
        },{
          path: '/MenuHtml/discover',
          name:'发现',
          mode:'history',
          component: resolve => require(['../views/MenuHtml/discover.vue'], resolve),
          meta: {
            requireAuth: true,// 添加该字段，表示进入这个路由是需要登录的
          },
        },{
          path: '/MenuHtml/recycle',
          name:'回收站',
          component: resolve => require(['../views/MenuHtml/recycle.vue'], resolve),
          meta: {
            requireAuth: true,// 添加该字段，表示进入这个路由是需要登录的
          },
        },
        {
          path: '/MenuHtml/look',
          name:'看一看',
          component: resolve => require(['../views/MenuHtml/look.vue'], resolve),
          meta: {
            requireAuth: true,// 添加该字段，表示进入这个路由是需要登录的
          },
        },
        {
          path: '/MenuHtml/instrument',
          name:'工具',
          component: resolve => require(['../views/MenuHtml/instrument.vue'], resolve),
          meta: {
            requireAuth: true,// 添加该字段，表示进入这个路由是需要登录的
          },
        }

        // {
        //   path: "/404",
        //   name: "notFound",
        //   component: notFound,
        //   meta: {
        //     requireAuth: true,// 添加该字段，表示进入这个路由是需要登录的
        //   },
        // }, {
        //   path: "/*", // 此处需特别注意置于最底部
        //   redirect: "/404",
        //   meta: {
        //     requireAuth: true,// 添加该字段，表示进入这个路由是需要登录的
        //   },
        // }

      ],
    },
     {
        path: '/',
        name: '',
        component: login,
        hidden: true,
        meta: {
            requireAuth: false
        }
    },{
      path: '/login',
      name: 'login',
      component: login,
      hidden: true,
      meta: {
        requireAuth: false
      }
    },{
        path: '/401',
        name: '401',
        component: a401,
        hidden: true,
        meta: {
          requireAuth: false
        }
      }, {
        path: '/home',
        name: 'home',
        component: home,

        meta: {
            requireAuth: false
        }
    },{
      path: '/sindex',
      name: '书签首页',
      component: sindex,
      hidden: true,
      meta: {
        requireAuth: true
      }
    },{
      path: '/bookmark',
      name: '登录',
      component: Ibookmark,
      hidden: true,
      meta: {
        requireAuth: false
      }
    },{
        path: '/index',
        name: '首页',
        component: index,
        iconCls: 'el-icon-tickets',
        children: [{
            path: '/goods/Goods',
            name: '商品管理',
            component: Goods,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/machine/Machine',
            name: '机器信息管理',
            component: Machine,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/machine/MachineAisle',
            name: '货道信息管理',
            component: MachineAisle,
            meta: {
                requireAuth: true
            }
        },{
  path: '/MenuHtml/Import',
    name: '导入',
    component: Import,
    meta: {
    requireAuth: true
  }
} ,{
            path: '/pay/Order',
            name: '交易订单',
            component: Order,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/system/user',
            name: '用户管理',
            component: user,
            meta: {
                requireAuth: true
            }
        },  {
          path: '/system/Module',
          name: '菜单管理2',
          component: Module,
          meta: {
            requireAuth: true
          }
        },{
          path: '/menuStree',
          name: '菜单管理4',
          component: menuStree,
          meta: {
            requireAuth: true
          }
        },{
            path: '/system/Role',
            name: '角色管理',
            component: Role,
            meta: {
                requireAuth: true
            }
        },
          {
            path: '/system/bookmark',
            name: '书签管理',
            component: bookmark,
            meta: {
              requireAuth: true
            }
          },
          {
            path: '/system/Dept',
            name: '公司管理',
            component: Dept,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/system/Variable',
            name: '系统环境变量',
            component: Variable,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/system/Permission',
            name: '权限管理',
            component: Permission,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/machine/MachineConfig',
            name: '支付配置信息',
            component: MachineConfig,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/pay/Config',
            name: '支付配置',
            component: Config,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/druid/login',
            name: '监控查询',
            component: druidLogin,
            meta: {
                requireAuth: true
            }
        }, {
            path: '/charts/statistics',
            name: '数据可视化',
            component: statistics,
            meta: {
                requireAuth: true
            }
        },{
            path: '/web/bookmark',
            name: '书签',
            hidden: true,
            component: webbookmark,
            meta: {
              requireAuth: false
            }
          },
          {
            path: '/aaa',
            name: '书签22',
            hidden: true,
            component: aaa,
            meta: {
              requireAuth: false
            }
          },
          // {
          //   path: "/404",
          //   name: "notFound",
          //   component: notFound
          // }, {
          //   path: "/*", // 此处需特别注意置于最底部
          //   redirect: "/404"
          // }
        ]

    }
    ],
  mode:'history'  //去#号
})
